package com.you.concurrent.test;

import java.util.concurrent.atomic.AtomicInteger;

public class Main {

    private static final int COUNT_BITS = Integer.SIZE - 3;
    private static final int RUNNING = -1 << COUNT_BITS;
    private static final int CAPACITY   = (1 << COUNT_BITS) - 1;
    private static int workerCountOf(int c)  { return c & CAPACITY; }

    private static int ctlOf(int rs, int wc) {
        return rs | wc;
    }

    public static void main(String[] args) {
        System.out.println(-1 << (COUNT_BITS));
        System.out.println((1 << COUNT_BITS) - 1);
        AtomicInteger ctl = new AtomicInteger(ctlOf(RUNNING, 0));
        System.out.println("ctl is : " + ctl);
        System.out.println(workerCountOf(ctl.get()));
    }
}
